package org.lixf.biz.impl;

import org.lixf.biz.DepartmentBiz;
import org.lixf.entity.Department;
import org.lixf.mapper.DepartmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class DepartmentBizImpl implements DepartmentBiz {
    @Autowired
    private DepartmentMapper departmentMapper;

    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public void add(Department department) {
        departmentMapper.insert(department);
    }

    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public void edit(Department department) {
        departmentMapper.update(department);
    }

    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public void remove(String sn) {
        departmentMapper.delete(sn);
    }

    @Transactional(readOnly = true)
    public Department get(String sn) {
        return departmentMapper.select(sn);
    }

    @Transactional(readOnly = true)
    public List<Department> getAll() {
        return departmentMapper.selectAll();
    }
}
